#include <iostream>
#include <set>
using namespace std;


int main (){
    int numA = 0, numB = 0;
    cin >> numA >> numB;
    set<int> unionAB;

    int num;
    while(numA--){
        cin >> num;
        unionAB.insert(num);
    }

    while(numB--){
        cin >> num;
        unionAB.insert(num);
    }

    for (auto elem: unionAB){
        cout <<  elem << " ";
    }
    cout  << endl;

    return 0;
}